# ALARM: Kevin Mihelich <kevin@archlinuxarm.org>
# Contributor: Jason Plum <jplum@archlinuxarm.org>

plugrel=1

_github_user=WarheadsSE
_github_repo=mochad
_github_commitID=1c34250ba8a1d739e5ada25965219b4471b9ad18


pkgname=mochad
pkgver=0.1.15
pkgrel=2
pkgdesc="A Linux TCP gateway daemon for the X10 CM15A RF and PL controller and the CM19A RF controller"
arch=('arm' 'armv6h' 'armv7h')
license=('GPL')
url="http://mochad.sourceforge.net/"
depends=('libusbx')
source=(mochad-${pkgver}.tar.gz::https://github.com/${_github_user}/${_github_repo}/tarball/${_github_commitID}
        mochad.service)
md5sums=('411f9d5350f48ca49ea8ba55ff5869d2'
         'e62206a10aba4bb4a7404a40a0e0d1b1')

build() {
  cd "${srcdir}/${_github_user}-${_github_repo}-${_github_commitID:0:7}"

  ./autogen.sh
  ./configure --prefix=/usr --disable-dependency-tracking
  make
}

package() {
  cd "${srcdir}/${_github_user}-${_github_repo}-${_github_commitID:0:7}"

  make DESTDIR="${pkgdir}" install-binPROGRAMS
  make DESTDIR="${pkgdir}" install-data-am
  install -D udev/91-usb-x10-controllers.rules "${pkgdir}/etc/udev/rules.d/91-usb-x10-controllers.rules"
  # install -D hotplug2/20-usb-x10 "${pkgdir}/etc/hotplug.d/usb/20-usb-x10"
  # install -D hotplug2/mochad "${pkgdir}/etc/rc.d/mochad"
  
  cd "${srcdir}"
  mkdir -p "${pkgdir}/usr/lib/systemd/system/"
  cp mochad.service "${pkgdir}/usr/lib/systemd/system/mochad.service"
  # install -D mochad.rc.d "${pkgdir}/etc/rc.d/mochad"
}
